package com.example.mapper.carecommunity.daycare;

import com.example.bean.carecommunity.SheQujujia;
import com.example.bean.carecommunity.Vo.RiZhaoVO;
import com.example.bean.configuration.zhibiaosystem.XzLiebiao;
import com.example.bean.configuration.zhibiaosystem.Zhibiao;
import com.example.bean.institutioncare.institutionadmin.Basicdata;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
@Mapper
public interface RijianzhaoliaoMapper {
    List<SheQujujia> selectTijianzhaoliaoAll(RiZhaoVO riZhaoVO);

    @Select("select * from zhibiao where zbx_name=#{leixiangming} and status='0'")
    Zhibiao getzhibiao(String leixiangming);

    @Select("select * from xz_liebiao where zb_id=#{noid} and status='0'")
    List<XzLiebiao> getxiangzhi(String noid);

    @Select("select * from t_basicinformation")
    List<Basicdata> getbasiAll();

    Integer addrizhao(SheQujujia rijianzhaoliao);

    @Update("update rijianzhaoliao set is_xiaofangyijian=1,is_shiyaojianyijian=1,is_huanpingyijian=1,is_other=1 where noid=#{noid}")
    Integer updateXukeBasc(String noid);

    @Update("update rijianzhaoliao set is_xiaofangyijian=0 where noid=#{noid}")
    Integer updatea(String noid);

    @Update("update rijianzhaoliao set is_shiyaojianyijian=0 where noid=#{noid}")
    Integer updateb(String noid);

    @Update("update rijianzhaoliao set is_huanpingyijian=0 where noid=#{noid}")
    Integer updatec(String noid);

    @Update("update rijianzhaoliao set is_other=0 where noid=#{noid}")
    Integer updated(String noid);

    @Insert("insert into shequjujia_zhibiao values(replace(uuid(),'-',''),#{noid},#{fuwuxiangid},#{index})")
    Integer addzhongjian(@Param("index") String index,@Param("fuwuxiangid") String fuwuxiangid,@Param("noid") String noid);

    @Select("select * from t_basicinformation where noid=#{jigouId}")
    SheQujujia selectJiGou(String jigouId);

    @Update("update rijianzhaoliao set is_delete=0 where noid=#{index}")
    Integer updateStutaDelete(String index);

    SheQujujia lookrizhao(String noid);

    @Select("select shequjujia_zhibiao.zhibiaozhi_id from shequjujia_zhibiao left join xz_liebiao on shequjujia_zhibiao.zhibiaozhi_id=xz_liebiao.noid where rijianzhaoliao_id=#{noid}")
    ArrayList<String> lookXiangzhi(String noid);

    @Select("select shequjujia_zhibiao.zhibiaoxiang_id from shequjujia_zhibiao where shequjujia_zhibiao.rijianzhaoliao_id=#{noid} limit 0,1")
    String lookFuwuxiangid(String noid);

    @Select("select zhibiao.* from shequjujia_zhibiao left join zhibiao on shequjujia_zhibiao.zhibiaoxiang_id=zhibiao.noid where shequjujia_zhibiao.rijianzhaoliao_id=#{noid} limit 0,1")
    Zhibiao getxiangzhilist(String noid);

    @Update("update rijianzhaoliao set jigou_id=#{jigouId},kaiban_date=#{kaibanDate},xingzhengquhua=#{xingzhengquhua},constructor_code=#{constructorCode},xuke=#{xuke},farenxingzhi=#{farenxingzhi},farenxinxi=#{farenxinxi},zhuti=#{zhuti},quantity=#{quantity},xingzhi=#{xingzhi},moshi=#{moshi},wenjian=#{wenjian},images=#{images},longitude=#{longitude},latitude=#{latitude},dingwei=#{dingwei},update_time=now(),extremely_needySupportType=#{extremelyNeedySupportType},institutions_nature=#{institutionsNature} where noid=#{noid}")
    Integer updatezhubiao(SheQujujia rijianzhaoliao);

    @Delete("delete from shequjujia_zhibiao where rijianzhaoliao_id=#{noid}")
    Integer deletezhogjian(String noid);

}